﻿
/*
 * 文件描述：该文件由代码生成器自动生成，请勿更改
 * 创建时间：2013/4/28 0:06:05
*/
using System;
using System.Collections.Generic;
using System.Data;
using DbMapping;
using DbMapping.Common;
using VideoCache.Server.Model;

namespace VideoCache.Server.DAL
{
		
		/// <summary>
		/// Map to Table t_agent
		/// </summary>
		public partial class AgentDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_agent WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_agent WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_agent WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_agent WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_agent(Name,ContactPerson,Province,City,Address,Telephone,Mobile,CompanyType,Status,UserId,ParentCompanyId,CreateTime,ModifyTime) VALUES(?Name,?ContactPerson,?Province,?City,?Address,?Telephone,?Mobile,?CompanyType,?Status,?UserId,?ParentCompanyId,?CreateTime,?ModifyTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_agent SET Name=?Name,ContactPerson=?ContactPerson,Province=?Province,City=?City,Address=?Address,Telephone=?Telephone,Mobile=?Mobile,CompanyType=?CompanyType,Status=?Status,UserId=?UserId,ParentCompanyId=?ParentCompanyId,CreateTime=?CreateTime,ModifyTime=?ModifyTime WHERE 1=1 ";

			public static List<AgentInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<AgentInfo> list = new List<AgentInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<AgentInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<AgentInfo> list = new List<AgentInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static AgentInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(AgentInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("Mobile", info.Mobile));
				
				paramList.Add(DbAccess.CreateParameter("CompanyType", info.CompanyType));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("ParentCompanyId", info.ParentCompanyId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, AgentInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("Mobile", info.Mobile));
				
				paramList.Add(DbAccess.CreateParameter("CompanyType", info.CompanyType));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("ParentCompanyId", info.ParentCompanyId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(AgentInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("Mobile", info.Mobile));
				
				paramList.Add(DbAccess.CreateParameter("CompanyType", info.CompanyType));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("ParentCompanyId", info.ParentCompanyId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, AgentInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, AgentInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("Mobile", info.Mobile));
				
				paramList.Add(DbAccess.CreateParameter("CompanyType", info.CompanyType));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("ParentCompanyId", info.ParentCompanyId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, AgentInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static AgentInfo GetModel(DataRow row)
			{
				AgentInfo info = new AgentInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.ContactPerson = DbAccess.GetValue<System.String>(row["ContactPerson"]);
				info.Province = DbAccess.GetValue<System.String>(row["Province"]);
				info.City = DbAccess.GetValue<System.String>(row["City"]);
				info.Address = DbAccess.GetValue<System.String>(row["Address"]);
				info.Telephone = DbAccess.GetValue<System.String>(row["Telephone"]);
				info.Mobile = DbAccess.GetValue<System.String>(row["Mobile"]);
				info.CompanyType = DbAccess.GetValue<System.Int32>(row["CompanyType"]);
				info.Status = DbAccess.GetValue<System.Int32>(row["Status"]);
				info.UserId = DbAccess.GetValue<System.Int32>(row["UserId"]);
				info.ParentCompanyId = DbAccess.GetValue<System.Int32>(row["ParentCompanyId"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				
				return info;
			}

						
			
			public static AgentInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_album
		/// </summary>
		public partial class AlbumDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_album WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_album WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_album WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_album WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_album(Title,TypeId,AreaId,Rating,Actor,Director,PubYear,IsEnd,Priority,Hash,Status,BaiduId,CreateTime,ModifyTime) VALUES(?Title,?TypeId,?AreaId,?Rating,?Actor,?Director,?PubYear,?IsEnd,?Priority,?Hash,?Status,?BaiduId,?CreateTime,?ModifyTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_album SET Title=?Title,TypeId=?TypeId,AreaId=?AreaId,Rating=?Rating,Actor=?Actor,Director=?Director,PubYear=?PubYear,IsEnd=?IsEnd,Priority=?Priority,Hash=?Hash,Status=?Status,BaiduId=?BaiduId,CreateTime=?CreateTime,ModifyTime=?ModifyTime WHERE 1=1 ";

			public static List<AlbumInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<AlbumInfo> list = new List<AlbumInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<AlbumInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<AlbumInfo> list = new List<AlbumInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static AlbumInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(AlbumInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Title", info.Title));
				
				paramList.Add(DbAccess.CreateParameter("TypeId", info.TypeId));
				
				paramList.Add(DbAccess.CreateParameter("AreaId", info.AreaId));
				
				paramList.Add(DbAccess.CreateParameter("Rating", info.Rating));
				
				paramList.Add(DbAccess.CreateParameter("Actor", info.Actor));
				
				paramList.Add(DbAccess.CreateParameter("Director", info.Director));
				
				paramList.Add(DbAccess.CreateParameter("PubYear", info.PubYear));
				
				paramList.Add(DbAccess.CreateParameter("IsEnd", info.IsEnd));
				
				paramList.Add(DbAccess.CreateParameter("Priority", info.Priority));
				
				paramList.Add(DbAccess.CreateParameter("Hash", info.Hash));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("BaiduId", info.BaiduId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, AlbumInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Title", info.Title));
				
				paramList.Add(DbAccess.CreateParameter("TypeId", info.TypeId));
				
				paramList.Add(DbAccess.CreateParameter("AreaId", info.AreaId));
				
				paramList.Add(DbAccess.CreateParameter("Rating", info.Rating));
				
				paramList.Add(DbAccess.CreateParameter("Actor", info.Actor));
				
				paramList.Add(DbAccess.CreateParameter("Director", info.Director));
				
				paramList.Add(DbAccess.CreateParameter("PubYear", info.PubYear));
				
				paramList.Add(DbAccess.CreateParameter("IsEnd", info.IsEnd));
				
				paramList.Add(DbAccess.CreateParameter("Priority", info.Priority));
				
				paramList.Add(DbAccess.CreateParameter("Hash", info.Hash));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("BaiduId", info.BaiduId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(AlbumInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Title", info.Title));
				
				paramList.Add(DbAccess.CreateParameter("TypeId", info.TypeId));
				
				paramList.Add(DbAccess.CreateParameter("AreaId", info.AreaId));
				
				paramList.Add(DbAccess.CreateParameter("Rating", info.Rating));
				
				paramList.Add(DbAccess.CreateParameter("Actor", info.Actor));
				
				paramList.Add(DbAccess.CreateParameter("Director", info.Director));
				
				paramList.Add(DbAccess.CreateParameter("PubYear", info.PubYear));
				
				paramList.Add(DbAccess.CreateParameter("IsEnd", info.IsEnd));
				
				paramList.Add(DbAccess.CreateParameter("Priority", info.Priority));
				
				paramList.Add(DbAccess.CreateParameter("Hash", info.Hash));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("BaiduId", info.BaiduId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, AlbumInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, AlbumInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Title", info.Title));
				
				paramList.Add(DbAccess.CreateParameter("TypeId", info.TypeId));
				
				paramList.Add(DbAccess.CreateParameter("AreaId", info.AreaId));
				
				paramList.Add(DbAccess.CreateParameter("Rating", info.Rating));
				
				paramList.Add(DbAccess.CreateParameter("Actor", info.Actor));
				
				paramList.Add(DbAccess.CreateParameter("Director", info.Director));
				
				paramList.Add(DbAccess.CreateParameter("PubYear", info.PubYear));
				
				paramList.Add(DbAccess.CreateParameter("IsEnd", info.IsEnd));
				
				paramList.Add(DbAccess.CreateParameter("Priority", info.Priority));
				
				paramList.Add(DbAccess.CreateParameter("Hash", info.Hash));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("BaiduId", info.BaiduId));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, AlbumInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static AlbumInfo GetModel(DataRow row)
			{
				AlbumInfo info = new AlbumInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Title = DbAccess.GetValue<System.String>(row["Title"]);
				info.TypeId = DbAccess.GetValue<System.Int32>(row["TypeId"]);
				info.AreaId = DbAccess.GetValue<System.Int32>(row["AreaId"]);
				info.Rating = DbAccess.GetValue<System.Int32>(row["Rating"]);
				info.Actor = DbAccess.GetValue<System.String>(row["Actor"]);
				info.Director = DbAccess.GetValue<System.String>(row["Director"]);
				info.PubYear = DbAccess.GetValue<System.Int32>(row["PubYear"]);
				info.IsEnd = DbAccess.GetValue<System.UInt64>(row["IsEnd"]);
				info.Priority = DbAccess.GetValue<System.Int32>(row["Priority"]);
				info.Hash = DbAccess.GetValue<System.String>(row["Hash"]);
				info.Status = DbAccess.GetValue<System.Int32>(row["Status"]);
				info.BaiduId = DbAccess.GetValue<System.Int32>(row["BaiduId"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				
				return info;
			}

						
			
			public static AlbumInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_album_description
		/// </summary>
		public partial class AlbumDescriptionDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_album_description WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_album_description WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_album_description WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_album_description WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_album_description(AlbumId,Description) VALUES(?AlbumId,?Description);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_album_description SET AlbumId=?AlbumId,Description=?Description WHERE 1=1 ";

			public static List<AlbumDescriptionInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<AlbumDescriptionInfo> list = new List<AlbumDescriptionInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<AlbumDescriptionInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<AlbumDescriptionInfo> list = new List<AlbumDescriptionInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static AlbumDescriptionInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(AlbumDescriptionInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("Description", info.Description));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, AlbumDescriptionInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("Description", info.Description));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(AlbumDescriptionInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("Description", info.Description));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, AlbumDescriptionInfo.AlbumIdField, CompareType.Equal, info.AlbumId));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, AlbumDescriptionInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("Description", info.Description));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, AlbumDescriptionInfo.AlbumIdField, CompareType.Equal, info.AlbumId));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static AlbumDescriptionInfo GetModel(DataRow row)
			{
				AlbumDescriptionInfo info = new AlbumDescriptionInfo();

				info.AlbumId = DbAccess.GetValue<System.Int32>(row["AlbumId"]);
				info.Description = DbAccess.GetValue<System.String>(row["Description"]);
				
				return info;
			}

						
			
			public static AlbumDescriptionInfo Find(System.Int32 _AlbumId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?AlbumId", _AlbumId));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND AlbumId=?AlbumId LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _AlbumId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?AlbumId", _AlbumId));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND AlbumId=?AlbumId", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _AlbumId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?AlbumId", _AlbumId));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND AlbumId=?AlbumId", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _AlbumId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?AlbumId", _AlbumId));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND AlbumId=?AlbumId", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_channel_token
		/// </summary>
		public partial class ChannelTokenDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_channel_token WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_channel_token WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_channel_token WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_channel_token WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_channel_token(ChannelId,Token,VideoName,RequestTimes) VALUES(?ChannelId,?Token,?VideoName,?RequestTimes);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_channel_token SET ChannelId=?ChannelId,Token=?Token,VideoName=?VideoName,RequestTimes=?RequestTimes WHERE 1=1 ";

			public static List<ChannelTokenInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<ChannelTokenInfo> list = new List<ChannelTokenInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<ChannelTokenInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<ChannelTokenInfo> list = new List<ChannelTokenInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static ChannelTokenInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(ChannelTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("VideoName", info.VideoName));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, ChannelTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("VideoName", info.VideoName));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(ChannelTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("VideoName", info.VideoName));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, ChannelTokenInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, ChannelTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("VideoName", info.VideoName));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, ChannelTokenInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static ChannelTokenInfo GetModel(DataRow row)
			{
				ChannelTokenInfo info = new ChannelTokenInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.ChannelId = DbAccess.GetValue<System.Int32>(row["ChannelId"]);
				info.Token = DbAccess.GetValue<System.String>(row["Token"]);
				info.VideoName = DbAccess.GetValue<System.String>(row["VideoName"]);
				info.RequestTimes = DbAccess.GetValue<System.Int32>(row["RequestTimes"]);
				
				return info;
			}

						
			
			public static ChannelTokenInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_channel_url
		/// </summary>
		public partial class ChannelUrlDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_channel_url WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_channel_url WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_channel_url WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_channel_url WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_channel_url(ChannelId,TokenId,Url) VALUES(?ChannelId,?TokenId,?Url);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_channel_url SET ChannelId=?ChannelId,TokenId=?TokenId,Url=?Url WHERE 1=1 ";

			public static List<ChannelUrlInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<ChannelUrlInfo> list = new List<ChannelUrlInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<ChannelUrlInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<ChannelUrlInfo> list = new List<ChannelUrlInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static ChannelUrlInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(ChannelUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, ChannelUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(ChannelUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, ChannelUrlInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, ChannelUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ChannelId", info.ChannelId));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, ChannelUrlInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static ChannelUrlInfo GetModel(DataRow row)
			{
				ChannelUrlInfo info = new ChannelUrlInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.ChannelId = DbAccess.GetValue<System.Int32>(row["ChannelId"]);
				info.TokenId = DbAccess.GetValue<System.Int32>(row["TokenId"]);
				info.Url = DbAccess.GetValue<System.String>(row["Url"]);
				
				return info;
			}

						
			
			public static ChannelUrlInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_dictionary
		/// </summary>
		public partial class DictionaryDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_dictionary WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_dictionary WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_dictionary WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_dictionary WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_dictionary(Name,ParentId) VALUES(?Name,?ParentId);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_dictionary SET Name=?Name,ParentId=?ParentId WHERE 1=1 ";

			public static List<DictionaryInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<DictionaryInfo> list = new List<DictionaryInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<DictionaryInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<DictionaryInfo> list = new List<DictionaryInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static DictionaryInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(DictionaryInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ParentId", info.ParentId));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, DictionaryInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ParentId", info.ParentId));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(DictionaryInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ParentId", info.ParentId));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, DictionaryInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, DictionaryInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("ParentId", info.ParentId));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, DictionaryInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static DictionaryInfo GetModel(DataRow row)
			{
				DictionaryInfo info = new DictionaryInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.ParentId = DbAccess.GetValue<System.Int32>(row["ParentId"]);
				
				return info;
			}

						
			
			public static DictionaryInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_episode
		/// </summary>
		public partial class EpisodeDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_episode WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_episode WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_episode WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_episode WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_episode(AlbumId,SiteId,EpisodeIndex,Name,Token,Url,CreateTime,ModifyTime,AllowDownload) VALUES(?AlbumId,?SiteId,?EpisodeIndex,?Name,?Token,?Url,?CreateTime,?ModifyTime,?AllowDownload);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_episode SET AlbumId=?AlbumId,SiteId=?SiteId,EpisodeIndex=?EpisodeIndex,Name=?Name,Token=?Token,Url=?Url,CreateTime=?CreateTime,ModifyTime=?ModifyTime,AllowDownload=?AllowDownload WHERE 1=1 ";

			public static List<EpisodeInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<EpisodeInfo> list = new List<EpisodeInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<EpisodeInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<EpisodeInfo> list = new List<EpisodeInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static EpisodeInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(EpisodeInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("EpisodeIndex", info.EpisodeIndex));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, EpisodeInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("EpisodeIndex", info.EpisodeIndex));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(EpisodeInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("EpisodeIndex", info.EpisodeIndex));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, EpisodeInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, EpisodeInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("AlbumId", info.AlbumId));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("EpisodeIndex", info.EpisodeIndex));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, EpisodeInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static EpisodeInfo GetModel(DataRow row)
			{
				EpisodeInfo info = new EpisodeInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.AlbumId = DbAccess.GetValue<System.Int32>(row["AlbumId"]);
				info.SiteId = DbAccess.GetValue<System.Int32>(row["SiteId"]);
				info.EpisodeIndex = DbAccess.GetValue<System.Int32>(row["EpisodeIndex"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.Token = DbAccess.GetValue<System.String>(row["Token"]);
				info.Url = DbAccess.GetValue<System.String>(row["Url"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				info.AllowDownload = DbAccess.GetValue<bool>(row["AllowDownload"]);
				
				return info;
			}

						
			
			public static EpisodeInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_netbar
		/// </summary>
		public partial class NetbarDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_netbar WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_netbar WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_netbar WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_netbar WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_netbar(Name,Password,Level,ExpiredTime,LastAuthTime,LastRequestTime,LastAuthIPAddress,LastRequestIPAddress,Session,Status,CreateTime,ModifyTime,Province,City,District,Address,ContactPerson,Telephone,MobilePhone,ComputerNumber,UserId,AgentID) VALUES(?Name,?Password,?Level,?ExpiredTime,?LastAuthTime,?LastRequestTime,?LastAuthIPAddress,?LastRequestIPAddress,?Session,?Status,?CreateTime,?ModifyTime,?Province,?City,?District,?Address,?ContactPerson,?Telephone,?MobilePhone,?ComputerNumber,?UserId,?AgentID);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_netbar SET Name=?Name,Password=?Password,Level=?Level,ExpiredTime=?ExpiredTime,LastAuthTime=?LastAuthTime,LastRequestTime=?LastRequestTime,LastAuthIPAddress=?LastAuthIPAddress,LastRequestIPAddress=?LastRequestIPAddress,Session=?Session,Status=?Status,CreateTime=?CreateTime,ModifyTime=?ModifyTime,Province=?Province,City=?City,District=?District,Address=?Address,ContactPerson=?ContactPerson,Telephone=?Telephone,MobilePhone=?MobilePhone,ComputerNumber=?ComputerNumber,UserId=?UserId,AgentID=?AgentID WHERE 1=1 ";

			public static List<NetbarInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<NetbarInfo> list = new List<NetbarInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<NetbarInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<NetbarInfo> list = new List<NetbarInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static NetbarInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(NetbarInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Level", info.Level));
				
				paramList.Add(DbAccess.CreateParameter("ExpiredTime", info.ExpiredTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthTime", info.LastAuthTime));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestTime", info.LastRequestTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthIPAddress", info.LastAuthIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestIPAddress", info.LastRequestIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("Session", info.Session));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("District", info.District));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("ComputerNumber", info.ComputerNumber));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("AgentID", info.AgentID));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, NetbarInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Level", info.Level));
				
				paramList.Add(DbAccess.CreateParameter("ExpiredTime", info.ExpiredTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthTime", info.LastAuthTime));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestTime", info.LastRequestTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthIPAddress", info.LastAuthIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestIPAddress", info.LastRequestIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("Session", info.Session));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("District", info.District));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("ComputerNumber", info.ComputerNumber));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("AgentID", info.AgentID));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(NetbarInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Level", info.Level));
				
				paramList.Add(DbAccess.CreateParameter("ExpiredTime", info.ExpiredTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthTime", info.LastAuthTime));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestTime", info.LastRequestTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthIPAddress", info.LastAuthIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestIPAddress", info.LastRequestIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("Session", info.Session));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("District", info.District));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("ComputerNumber", info.ComputerNumber));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("AgentID", info.AgentID));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, NetbarInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, NetbarInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Level", info.Level));
				
				paramList.Add(DbAccess.CreateParameter("ExpiredTime", info.ExpiredTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthTime", info.LastAuthTime));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestTime", info.LastRequestTime));
				
				paramList.Add(DbAccess.CreateParameter("LastAuthIPAddress", info.LastAuthIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("LastRequestIPAddress", info.LastRequestIPAddress));
				
				paramList.Add(DbAccess.CreateParameter("Session", info.Session));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				paramList.Add(DbAccess.CreateParameter("District", info.District));
				
				paramList.Add(DbAccess.CreateParameter("Address", info.Address));
				
				paramList.Add(DbAccess.CreateParameter("ContactPerson", info.ContactPerson));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("ComputerNumber", info.ComputerNumber));
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("AgentID", info.AgentID));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, NetbarInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static NetbarInfo GetModel(DataRow row)
			{
				NetbarInfo info = new NetbarInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.Password = DbAccess.GetValue<System.String>(row["Password"]);
				info.Level = DbAccess.GetValue<System.Int32>(row["Level"]);
				info.ExpiredTime = DbAccess.GetValue<System.DateTime>(row["ExpiredTime"]);
				info.LastAuthTime = DbAccess.GetValue<System.DateTime>(row["LastAuthTime"]);
				info.LastRequestTime = DbAccess.GetValue<System.DateTime>(row["LastRequestTime"]);
				info.LastAuthIPAddress = DbAccess.GetValue<System.Int32>(row["LastAuthIPAddress"]);
				info.LastRequestIPAddress = DbAccess.GetValue<System.Int32>(row["LastRequestIPAddress"]);
				info.Session = DbAccess.GetValue<System.String>(row["Session"]);
				info.Status = DbAccess.GetValue<System.Int32>(row["Status"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				info.Province = DbAccess.GetValue<System.String>(row["Province"]);
				info.City = DbAccess.GetValue<System.String>(row["City"]);
				info.District = DbAccess.GetValue<System.String>(row["District"]);
				info.Address = DbAccess.GetValue<System.String>(row["Address"]);
				info.ContactPerson = DbAccess.GetValue<System.String>(row["ContactPerson"]);
				info.Telephone = DbAccess.GetValue<System.String>(row["Telephone"]);
				info.MobilePhone = DbAccess.GetValue<System.String>(row["MobilePhone"]);
				info.ComputerNumber = DbAccess.GetValue<System.Int32>(row["ComputerNumber"]);
				info.UserId = DbAccess.GetValue<System.Int32>(row["UserId"]);
				info.AgentID = DbAccess.GetValue<System.Int32>(row["AgentID"]);
				
				return info;
			}

						
			
			public static NetbarInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_order
		/// </summary>
		public partial class OrderDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_order WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_order WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_order WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_order WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_order(Id,ProductId,UnitPrice,Quantity,TotalPrice,UseId,Status,CreateTime,ModifyTime) VALUES(?Id,?ProductId,?UnitPrice,?Quantity,?TotalPrice,?UseId,?Status,?CreateTime,?ModifyTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_order SET Id=?Id,ProductId=?ProductId,UnitPrice=?UnitPrice,Quantity=?Quantity,TotalPrice=?TotalPrice,UseId=?UseId,Status=?Status,CreateTime=?CreateTime,ModifyTime=?ModifyTime WHERE 1=1 ";

			public static List<OrderInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<OrderInfo> list = new List<OrderInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<OrderInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<OrderInfo> list = new List<OrderInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static OrderInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(OrderInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ProductId", info.ProductId));
				
				paramList.Add(DbAccess.CreateParameter("UnitPrice", info.UnitPrice));
				
				paramList.Add(DbAccess.CreateParameter("Quantity", info.Quantity));
				
				paramList.Add(DbAccess.CreateParameter("TotalPrice", info.TotalPrice));
				
				paramList.Add(DbAccess.CreateParameter("UseId", info.UseId));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, OrderInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ProductId", info.ProductId));
				
				paramList.Add(DbAccess.CreateParameter("UnitPrice", info.UnitPrice));
				
				paramList.Add(DbAccess.CreateParameter("Quantity", info.Quantity));
				
				paramList.Add(DbAccess.CreateParameter("TotalPrice", info.TotalPrice));
				
				paramList.Add(DbAccess.CreateParameter("UseId", info.UseId));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(OrderInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ProductId", info.ProductId));
				
				paramList.Add(DbAccess.CreateParameter("UnitPrice", info.UnitPrice));
				
				paramList.Add(DbAccess.CreateParameter("Quantity", info.Quantity));
				
				paramList.Add(DbAccess.CreateParameter("TotalPrice", info.TotalPrice));
				
				paramList.Add(DbAccess.CreateParameter("UseId", info.UseId));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, OrderInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, OrderInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("ProductId", info.ProductId));
				
				paramList.Add(DbAccess.CreateParameter("UnitPrice", info.UnitPrice));
				
				paramList.Add(DbAccess.CreateParameter("Quantity", info.Quantity));
				
				paramList.Add(DbAccess.CreateParameter("TotalPrice", info.TotalPrice));
				
				paramList.Add(DbAccess.CreateParameter("UseId", info.UseId));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, OrderInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static OrderInfo GetModel(DataRow row)
			{
				OrderInfo info = new OrderInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.ProductId = DbAccess.GetValue<System.Int32>(row["ProductId"]);
				info.UnitPrice = DbAccess.GetValue<System.Decimal>(row["UnitPrice"]);
				info.Quantity = DbAccess.GetValue<System.Int32>(row["Quantity"]);
				info.TotalPrice = DbAccess.GetValue<System.Decimal>(row["TotalPrice"]);
				info.UseId = DbAccess.GetValue<System.Int32>(row["UseId"]);
				info.Status = DbAccess.GetValue<System.Int32>(row["Status"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				
				return info;
			}

						
			
			public static OrderInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_product
		/// </summary>
		public partial class ProductDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_product WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_product WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_product WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_product WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_product(Name,OriginalCost,Cost,Stock,ShortBrief,Status,ProductType,CreateTime,ModifyTime) VALUES(?Name,?OriginalCost,?Cost,?Stock,?ShortBrief,?Status,?ProductType,?CreateTime,?ModifyTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_product SET Name=?Name,OriginalCost=?OriginalCost,Cost=?Cost,Stock=?Stock,ShortBrief=?ShortBrief,Status=?Status,ProductType=?ProductType,CreateTime=?CreateTime,ModifyTime=?ModifyTime WHERE 1=1 ";

			public static List<ProductInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<ProductInfo> list = new List<ProductInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<ProductInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<ProductInfo> list = new List<ProductInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static ProductInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(ProductInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("OriginalCost", info.OriginalCost));
				
				paramList.Add(DbAccess.CreateParameter("Cost", info.Cost));
				
				paramList.Add(DbAccess.CreateParameter("Stock", info.Stock));
				
				paramList.Add(DbAccess.CreateParameter("ShortBrief", info.ShortBrief));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("ProductType", info.ProductType));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, ProductInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("OriginalCost", info.OriginalCost));
				
				paramList.Add(DbAccess.CreateParameter("Cost", info.Cost));
				
				paramList.Add(DbAccess.CreateParameter("Stock", info.Stock));
				
				paramList.Add(DbAccess.CreateParameter("ShortBrief", info.ShortBrief));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("ProductType", info.ProductType));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(ProductInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("OriginalCost", info.OriginalCost));
				
				paramList.Add(DbAccess.CreateParameter("Cost", info.Cost));
				
				paramList.Add(DbAccess.CreateParameter("Stock", info.Stock));
				
				paramList.Add(DbAccess.CreateParameter("ShortBrief", info.ShortBrief));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("ProductType", info.ProductType));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, ProductInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, ProductInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("OriginalCost", info.OriginalCost));
				
				paramList.Add(DbAccess.CreateParameter("Cost", info.Cost));
				
				paramList.Add(DbAccess.CreateParameter("Stock", info.Stock));
				
				paramList.Add(DbAccess.CreateParameter("ShortBrief", info.ShortBrief));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("ProductType", info.ProductType));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, ProductInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static ProductInfo GetModel(DataRow row)
			{
				ProductInfo info = new ProductInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.OriginalCost = DbAccess.GetValue<System.Decimal>(row["OriginalCost"]);
				info.Cost = DbAccess.GetValue<System.Decimal>(row["Cost"]);
				info.Stock = DbAccess.GetValue<System.Int32>(row["Stock"]);
				info.ShortBrief = DbAccess.GetValue<System.String>(row["ShortBrief"]);
				info.Status = DbAccess.GetValue<System.Int32>(row["Status"]);
				info.ProductType = DbAccess.GetValue<System.Int32>(row["ProductType"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				
				return info;
			}

						
			
			public static ProductInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_role
		/// </summary>
		public partial class RoleDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_role WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_role WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_role WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_role WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_role(Name,DisplayName) VALUES(?Name,?DisplayName);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_role SET Name=?Name,DisplayName=?DisplayName WHERE 1=1 ";

			public static List<RoleInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<RoleInfo> list = new List<RoleInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<RoleInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<RoleInfo> list = new List<RoleInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static RoleInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(RoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, RoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(RoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, RoleInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, RoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, RoleInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static RoleInfo GetModel(DataRow row)
			{
				RoleInfo info = new RoleInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.DisplayName = DbAccess.GetValue<System.String>(row["DisplayName"]);
				
				return info;
			}

						
			
			public static RoleInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_site
		/// </summary>
		public partial class SiteDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_site WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_site WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_site WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_site WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_site(Name,DisplayName,UrlHost,AllowDownload,PlayerId,PositionTag,Downloader,CreateTime,ModifyTime) VALUES(?Name,?DisplayName,?UrlHost,?AllowDownload,?PlayerId,?PositionTag,?Downloader,?CreateTime,?ModifyTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_site SET Name=?Name,DisplayName=?DisplayName,UrlHost=?UrlHost,AllowDownload=?AllowDownload,PlayerId=?PlayerId,PositionTag=?PositionTag,Downloader=?Downloader,CreateTime=?CreateTime,ModifyTime=?ModifyTime WHERE 1=1 ";

			public static List<SiteInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<SiteInfo> list = new List<SiteInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<SiteInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<SiteInfo> list = new List<SiteInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static SiteInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(SiteInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				paramList.Add(DbAccess.CreateParameter("UrlHost", info.UrlHost));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				paramList.Add(DbAccess.CreateParameter("PlayerId", info.PlayerId));
				
				paramList.Add(DbAccess.CreateParameter("PositionTag", info.PositionTag));
				
				paramList.Add(DbAccess.CreateParameter("Downloader", info.Downloader));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, SiteInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				paramList.Add(DbAccess.CreateParameter("UrlHost", info.UrlHost));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				paramList.Add(DbAccess.CreateParameter("PlayerId", info.PlayerId));
				
				paramList.Add(DbAccess.CreateParameter("PositionTag", info.PositionTag));
				
				paramList.Add(DbAccess.CreateParameter("Downloader", info.Downloader));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(SiteInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				paramList.Add(DbAccess.CreateParameter("UrlHost", info.UrlHost));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				paramList.Add(DbAccess.CreateParameter("PlayerId", info.PlayerId));
				
				paramList.Add(DbAccess.CreateParameter("PositionTag", info.PositionTag));
				
				paramList.Add(DbAccess.CreateParameter("Downloader", info.Downloader));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, SiteInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, SiteInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("DisplayName", info.DisplayName));
				
				paramList.Add(DbAccess.CreateParameter("UrlHost", info.UrlHost));
				
				paramList.Add(DbAccess.CreateParameter("AllowDownload", info.AllowDownload));
				
				paramList.Add(DbAccess.CreateParameter("PlayerId", info.PlayerId));
				
				paramList.Add(DbAccess.CreateParameter("PositionTag", info.PositionTag));
				
				paramList.Add(DbAccess.CreateParameter("Downloader", info.Downloader));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, SiteInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static SiteInfo GetModel(DataRow row)
			{
				SiteInfo info = new SiteInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.DisplayName = DbAccess.GetValue<System.String>(row["DisplayName"]);
				info.UrlHost = DbAccess.GetValue<System.String>(row["UrlHost"]);
				info.AllowDownload = DbAccess.GetValue<System.UInt64>(row["AllowDownload"]);
				info.PlayerId = DbAccess.GetValue<System.String>(row["PlayerId"]);
				info.PositionTag = DbAccess.GetValue<System.String>(row["PositionTag"]);
				info.Downloader = DbAccess.GetValue<System.String>(row["Downloader"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				
				return info;
			}

						
			
			public static SiteInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_site_channel
		/// </summary>
		public partial class SiteChannelDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_site_channel WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_site_channel WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_site_channel WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_site_channel WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_site_channel(Name,SiteId,Domain,UrlPattern,Assembly,Enable,CreateTime,ModifyTime) VALUES(?Name,?SiteId,?Domain,?UrlPattern,?Assembly,?Enable,?CreateTime,?ModifyTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_site_channel SET Name=?Name,SiteId=?SiteId,Domain=?Domain,UrlPattern=?UrlPattern,Assembly=?Assembly,Enable=?Enable,CreateTime=?CreateTime,ModifyTime=?ModifyTime WHERE 1=1 ";

			public static List<SiteChannelInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<SiteChannelInfo> list = new List<SiteChannelInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<SiteChannelInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<SiteChannelInfo> list = new List<SiteChannelInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static SiteChannelInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(SiteChannelInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Domain", info.Domain));
				
				paramList.Add(DbAccess.CreateParameter("UrlPattern", info.UrlPattern));
				
				paramList.Add(DbAccess.CreateParameter("Assembly", info.Assembly));
				
				paramList.Add(DbAccess.CreateParameter("Enable", info.Enable));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, SiteChannelInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Domain", info.Domain));
				
				paramList.Add(DbAccess.CreateParameter("UrlPattern", info.UrlPattern));
				
				paramList.Add(DbAccess.CreateParameter("Assembly", info.Assembly));
				
				paramList.Add(DbAccess.CreateParameter("Enable", info.Enable));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(SiteChannelInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Domain", info.Domain));
				
				paramList.Add(DbAccess.CreateParameter("UrlPattern", info.UrlPattern));
				
				paramList.Add(DbAccess.CreateParameter("Assembly", info.Assembly));
				
				paramList.Add(DbAccess.CreateParameter("Enable", info.Enable));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, SiteChannelInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, SiteChannelInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Domain", info.Domain));
				
				paramList.Add(DbAccess.CreateParameter("UrlPattern", info.UrlPattern));
				
				paramList.Add(DbAccess.CreateParameter("Assembly", info.Assembly));
				
				paramList.Add(DbAccess.CreateParameter("Enable", info.Enable));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, SiteChannelInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static SiteChannelInfo GetModel(DataRow row)
			{
				SiteChannelInfo info = new SiteChannelInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.SiteId = DbAccess.GetValue<System.Int32>(row["SiteId"]);
				info.Domain = DbAccess.GetValue<System.String>(row["Domain"]);
				info.UrlPattern = DbAccess.GetValue<System.String>(row["UrlPattern"]);
				info.Assembly = DbAccess.GetValue<System.String>(row["Assembly"]);
				info.Enable = DbAccess.GetValue<bool>(row["Enable"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				
				return info;
			}

						
			
			public static SiteChannelInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_site_token
		/// </summary>
		public partial class SiteTokenDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_site_token WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_site_token WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_site_token WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_site_token WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_site_token(SiteId,Token,RequestTimes) VALUES(?SiteId,?Token,?RequestTimes);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_site_token SET SiteId=?SiteId,Token=?Token,RequestTimes=?RequestTimes WHERE 1=1 ";

			public static List<SiteTokenInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<SiteTokenInfo> list = new List<SiteTokenInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<SiteTokenInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<SiteTokenInfo> list = new List<SiteTokenInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static SiteTokenInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(SiteTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, SiteTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(SiteTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, SiteTokenInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, SiteTokenInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("SiteId", info.SiteId));
				
				paramList.Add(DbAccess.CreateParameter("Token", info.Token));
				
				paramList.Add(DbAccess.CreateParameter("RequestTimes", info.RequestTimes));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, SiteTokenInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static SiteTokenInfo GetModel(DataRow row)
			{
				SiteTokenInfo info = new SiteTokenInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.SiteId = DbAccess.GetValue<System.Int32>(row["SiteId"]);
				info.Token = DbAccess.GetValue<System.String>(row["Token"]);
				info.RequestTimes = DbAccess.GetValue<System.Int32>(row["RequestTimes"]);
				
				return info;
			}

						
			
			public static SiteTokenInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_token_url
		/// </summary>
		public partial class TokenUrlDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_token_url WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_token_url WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_token_url WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_token_url WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_token_url(TokenId,Url) VALUES(?TokenId,?Url);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_token_url SET TokenId=?TokenId,Url=?Url WHERE 1=1 ";

			public static List<TokenUrlInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<TokenUrlInfo> list = new List<TokenUrlInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<TokenUrlInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<TokenUrlInfo> list = new List<TokenUrlInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static TokenUrlInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(TokenUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, TokenUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(TokenUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, TokenUrlInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, TokenUrlInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("TokenId", info.TokenId));
				
				paramList.Add(DbAccess.CreateParameter("Url", info.Url));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, TokenUrlInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static TokenUrlInfo GetModel(DataRow row)
			{
				TokenUrlInfo info = new TokenUrlInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.TokenId = DbAccess.GetValue<System.Int32>(row["TokenId"]);
				info.Url = DbAccess.GetValue<System.String>(row["Url"]);
				
				return info;
			}

						
			
			public static TokenUrlInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_user
		/// </summary>
		public partial class UserDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_user WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_user WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_user WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_user WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_user(UserName,Password,Email,Status,RegisterTime,ActiveTime,ActiveCode,LoginTime) VALUES(?UserName,?Password,?Email,?Status,?RegisterTime,?ActiveTime,?ActiveCode,?LoginTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_user SET UserName=?UserName,Password=?Password,Email=?Email,Status=?Status,RegisterTime=?RegisterTime,ActiveTime=?ActiveTime,ActiveCode=?ActiveCode,LoginTime=?LoginTime WHERE 1=1 ";

			public static List<UserInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<UserInfo> list = new List<UserInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<UserInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<UserInfo> list = new List<UserInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static UserInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(UserInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("UserName", info.UserName));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Email", info.Email));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("RegisterTime", info.RegisterTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveTime", info.ActiveTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveCode", info.ActiveCode));
				
				paramList.Add(DbAccess.CreateParameter("LoginTime", info.LoginTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, UserInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("UserName", info.UserName));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Email", info.Email));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("RegisterTime", info.RegisterTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveTime", info.ActiveTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveCode", info.ActiveCode));
				
				paramList.Add(DbAccess.CreateParameter("LoginTime", info.LoginTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(UserInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("UserName", info.UserName));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Email", info.Email));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("RegisterTime", info.RegisterTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveTime", info.ActiveTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveCode", info.ActiveCode));
				
				paramList.Add(DbAccess.CreateParameter("LoginTime", info.LoginTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, UserInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, UserInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("UserName", info.UserName));
				
				paramList.Add(DbAccess.CreateParameter("Password", info.Password));
				
				paramList.Add(DbAccess.CreateParameter("Email", info.Email));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("RegisterTime", info.RegisterTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveTime", info.ActiveTime));
				
				paramList.Add(DbAccess.CreateParameter("ActiveCode", info.ActiveCode));
				
				paramList.Add(DbAccess.CreateParameter("LoginTime", info.LoginTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, UserInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static UserInfo GetModel(DataRow row)
			{
				UserInfo info = new UserInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.UserName = DbAccess.GetValue<System.String>(row["UserName"]);
				info.Password = DbAccess.GetValue<System.String>(row["Password"]);
				info.Email = DbAccess.GetValue<System.String>(row["Email"]);
				info.Status = DbAccess.GetValue<System.Int32>(row["Status"]);
				info.RegisterTime = DbAccess.GetValue<System.DateTime>(row["RegisterTime"]);
				info.ActiveTime = DbAccess.GetValue<System.DateTime>(row["ActiveTime"]);
				info.ActiveCode = DbAccess.GetValue<System.String>(row["ActiveCode"]);
				info.LoginTime = DbAccess.GetValue<System.DateTime>(row["LoginTime"]);
				
				return info;
			}

						
			
			public static UserInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_user_profile
		/// </summary>
		public partial class UserProfileDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_user_profile WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_user_profile WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_user_profile WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_user_profile WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_user_profile(UserId,NickName,Sex,Birthday,Telephone,MobilePhone,RealName,Province,City) VALUES(?UserId,?NickName,?Sex,?Birthday,?Telephone,?MobilePhone,?RealName,?Province,?City);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_user_profile SET UserId=?UserId,NickName=?NickName,Sex=?Sex,Birthday=?Birthday,Telephone=?Telephone,MobilePhone=?MobilePhone,RealName=?RealName,Province=?Province,City=?City WHERE 1=1 ";

			public static List<UserProfileInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<UserProfileInfo> list = new List<UserProfileInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<UserProfileInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<UserProfileInfo> list = new List<UserProfileInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static UserProfileInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(UserProfileInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("NickName", info.NickName));
				
				paramList.Add(DbAccess.CreateParameter("Sex", info.Sex));
				
				paramList.Add(DbAccess.CreateParameter("Birthday", info.Birthday));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("RealName", info.RealName));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, UserProfileInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("NickName", info.NickName));
				
				paramList.Add(DbAccess.CreateParameter("Sex", info.Sex));
				
				paramList.Add(DbAccess.CreateParameter("Birthday", info.Birthday));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("RealName", info.RealName));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(UserProfileInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("NickName", info.NickName));
				
				paramList.Add(DbAccess.CreateParameter("Sex", info.Sex));
				
				paramList.Add(DbAccess.CreateParameter("Birthday", info.Birthday));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("RealName", info.RealName));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, UserProfileInfo.UserIdField, CompareType.Equal, info.UserId));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, UserProfileInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("NickName", info.NickName));
				
				paramList.Add(DbAccess.CreateParameter("Sex", info.Sex));
				
				paramList.Add(DbAccess.CreateParameter("Birthday", info.Birthday));
				
				paramList.Add(DbAccess.CreateParameter("Telephone", info.Telephone));
				
				paramList.Add(DbAccess.CreateParameter("MobilePhone", info.MobilePhone));
				
				paramList.Add(DbAccess.CreateParameter("RealName", info.RealName));
				
				paramList.Add(DbAccess.CreateParameter("Province", info.Province));
				
				paramList.Add(DbAccess.CreateParameter("City", info.City));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, UserProfileInfo.UserIdField, CompareType.Equal, info.UserId));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static UserProfileInfo GetModel(DataRow row)
			{
				UserProfileInfo info = new UserProfileInfo();

				info.UserId = DbAccess.GetValue<System.Int32>(row["UserId"]);
				info.NickName = DbAccess.GetValue<System.String>(row["NickName"]);
				info.Sex = DbAccess.GetValue<bool>(row["Sex"]);
				info.Birthday = DbAccess.GetValue<System.DateTime>(row["Birthday"]);
				info.Telephone = DbAccess.GetValue<System.String>(row["Telephone"]);
				info.MobilePhone = DbAccess.GetValue<System.String>(row["MobilePhone"]);
				info.RealName = DbAccess.GetValue<System.String>(row["RealName"]);
				info.Province = DbAccess.GetValue<System.String>(row["Province"]);
				info.City = DbAccess.GetValue<System.String>(row["City"]);
				
				return info;
			}

						
			
			public static UserProfileInfo Find(System.Int32 _UserId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND UserId=?UserId LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _UserId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND UserId=?UserId", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _UserId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND UserId=?UserId", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _UserId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND UserId=?UserId", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_user_role
		/// </summary>
		public partial class UserRoleDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_user_role WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_user_role WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_user_role WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_user_role WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_user_role(UserId,RoleId) VALUES(?UserId,?RoleId);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_user_role SET UserId=?UserId,RoleId=?RoleId WHERE 1=1 ";

			public static List<UserRoleInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<UserRoleInfo> list = new List<UserRoleInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<UserRoleInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<UserRoleInfo> list = new List<UserRoleInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static UserRoleInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(UserRoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("RoleId", info.RoleId));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, UserRoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("RoleId", info.RoleId));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(UserRoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("RoleId", info.RoleId));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, UserRoleInfo.UserIdField, CompareType.Equal, info.UserId));
				
				cons.Add(new ConditionItem(LinkType.And, UserRoleInfo.RoleIdField, CompareType.Equal, info.RoleId));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, UserRoleInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("UserId", info.UserId));
				
				paramList.Add(DbAccess.CreateParameter("RoleId", info.RoleId));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, UserRoleInfo.UserIdField, CompareType.Equal, info.UserId));
				
				cons.Add(new ConditionItem(LinkType.And, UserRoleInfo.RoleIdField, CompareType.Equal, info.RoleId));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static UserRoleInfo GetModel(DataRow row)
			{
				UserRoleInfo info = new UserRoleInfo();

				info.UserId = DbAccess.GetValue<System.Int32>(row["UserId"]);
				info.RoleId = DbAccess.GetValue<System.Int32>(row["RoleId"]);
				
				return info;
			}

						
			
			public static UserRoleInfo Find(System.Int32 _UserId, System.Int32 _RoleId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				paramList.Add(DbAccess.CreateParameter("?RoleId", _RoleId));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND UserId=?UserId AND RoleId=?RoleId LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _UserId, System.Int32 _RoleId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				paramList.Add(DbAccess.CreateParameter("?RoleId", _RoleId));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND UserId=?UserId AND RoleId=?RoleId", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _UserId, System.Int32 _RoleId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				paramList.Add(DbAccess.CreateParameter("?RoleId", _RoleId));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND UserId=?UserId AND RoleId=?RoleId", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _UserId, System.Int32 _RoleId)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?UserId", _UserId));
				
				paramList.Add(DbAccess.CreateParameter("?RoleId", _RoleId));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND UserId=?UserId AND RoleId=?RoleId", CommandType.Text, paramList.ToArray());
			}

			
		}
		
		/// <summary>
		/// Map to Table t_video
		/// </summary>
		public partial class VideoDAL
		{
			const string SQL_SELECT = "SELECT * FROM t_video WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM t_video WHERE 1=1 ";
			const string SQL_DELETE = "DElETE FROM  t_video WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM t_video WHERE 1=1 {0} {1} LIMIT {2},{3}";
			
			const string SQL_INSERT = "INSERT INTO t_video(Guid,Name,PlayCount,Status,CreateTime,ModifyTime) VALUES(?Guid,?Name,?PlayCount,?Status,?CreateTime,?ModifyTime);select LAST_INSERT_ID();";
			const string SQL_UPDATE = "UPDATE t_video SET Guid=?Guid,Name=?Name,PlayCount=?PlayCount,Status=?Status,CreateTime=?CreateTime,ModifyTime=?ModifyTime WHERE 1=1 ";

			public static List<VideoInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<VideoInfo> list = new List<VideoInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<VideoInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<VideoInfo> list = new List<VideoInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static VideoInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static int Add(VideoInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Guid", info.Guid));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("PlayCount", info.PlayCount));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static int Add(IDbTransaction tran, VideoInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Guid", info.Guid));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("PlayCount", info.PlayCount));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(tran, SQL_INSERT, CommandType.Text, paramList.ToArray()));
			}

			public static void Update(VideoInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Guid", info.Guid));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("PlayCount", info.PlayCount));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, VideoInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Update(IDbTransaction tran, VideoInfo info)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("Id", info.Id));
				
				paramList.Add(DbAccess.CreateParameter("Guid", info.Guid));
				
				paramList.Add(DbAccess.CreateParameter("Name", info.Name));
				
				paramList.Add(DbAccess.CreateParameter("PlayCount", info.PlayCount));
				
				paramList.Add(DbAccess.CreateParameter("Status", info.Status));
				
				paramList.Add(DbAccess.CreateParameter("CreateTime", info.CreateTime));
				
				paramList.Add(DbAccess.CreateParameter("ModifyTime", info.ModifyTime));
				
				Conditions cons = new Conditions();
				
				cons.Add(new ConditionItem(LinkType.And, VideoInfo.IdField, CompareType.Equal, info.Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_UPDATE, cons, paramList.ToArray());
			}

			public static void Delete(Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(SQL_DELETE, conditions);
			}

			public static void Delete(IDbTransaction tran, Conditions conditions)
			{
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE, conditions);
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static VideoInfo GetModel(DataRow row)
			{
				VideoInfo info = new VideoInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.Guid = DbAccess.GetValue<System.String>(row["Guid"]);
				info.Name = DbAccess.GetValue<System.String>(row["Name"]);
				info.PlayCount = DbAccess.GetValue<System.Int32>(row["PlayCount"]);
				info.Status = DbAccess.GetValue<System.Int32>(row["Status"]);
				info.CreateTime = DbAccess.GetValue<System.DateTime>(row["CreateTime"]);
				info.ModifyTime = DbAccess.GetValue<System.DateTime>(row["ModifyTime"]);
				
				return info;
			}

						
			
			public static VideoInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			public static void Delete(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			public static void Delete(IDbTransaction tran, System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DbAccess.ExecuteNonQuery(tran, SQL_DELETE + " AND Id=?Id", CommandType.Text, paramList.ToArray());
			}

			
		}
	
	#region Views

	
		
		/// <summary>
		/// Map to Table v_channel_url_token
		/// </summary>
		public partial class ChannelUrlTokenDAL
		{
			const string SQL_SELECT = "SELECT * FROM v_channel_url_token WHERE 1=1 ";
			const string SQL_EXISTS = "SELECT COUNT(*) FROM v_channel_url_token WHERE 1=1 ";
			const string SQL_PAGER  = "SELECT * FROM v_channel_url_token WHERE 1=1 {0} {1} LIMIT {2},{3}";

			public static List<ChannelUrlTokenInfo> FindAll(Conditions conditions, Orders orders)
			{
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT, conditions, orders);

				List<ChannelUrlTokenInfo> list = new List<ChannelUrlTokenInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static List<ChannelUrlTokenInfo> FindPage(Conditions conditions, Orders orders, int pageIndex, int pageSize, ref int recordCount)
			{
				recordCount = Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));

				string sql = string.Format(SQL_PAGER, DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions), orders.ToString(), (pageIndex - 1) * pageSize, pageSize);
				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				List<ChannelUrlTokenInfo> list = new List<ChannelUrlTokenInfo>();
				foreach(DataRow row in dt.Rows)
				{
					list.Add(GetModel(row));
				}

				return list;
			}

			public static ChannelUrlTokenInfo Find(Conditions conditions, Orders orders)
			{
				string sql = SQL_SELECT + DbAccess.GetConditionSql(ProviderFactory.GetProvider(), conditions) + " limit 0,1";

				DataTable dt = DbAccess.ExecuteDataTable(sql, CommandType.Text, DbAccess.GetParameters(conditions));

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(Conditions conditions)
			{
				return Count(conditions) > 0;
			}

			public static int Count(Conditions conditions)
			{
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS, conditions));
			}

			public static ChannelUrlTokenInfo GetModel(DataRow row)
			{
				ChannelUrlTokenInfo info = new ChannelUrlTokenInfo();

				info.Id = DbAccess.GetValue<System.Int32>(row["Id"]);
				info.ChannelId = DbAccess.GetValue<System.Int32>(row["ChannelId"]);
				info.TokenId = DbAccess.GetValue<System.Int32>(row["TokenId"]);
				info.Url = DbAccess.GetValue<System.String>(row["Url"]);
				info.Token = DbAccess.GetValue<System.String>(row["Token"]);
				info.VideoName = DbAccess.GetValue<System.String>(row["VideoName"]);
				info.RequestTimes = DbAccess.GetValue<System.Int32>(row["RequestTimes"]);
				
				return info;
			}

						
			
			public static ChannelUrlTokenInfo Find(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				DataTable dt = DbAccess.ExecuteDataTable(SQL_SELECT + " AND Id=?Id LIMIT 0,1", CommandType.Text, paramList.ToArray());

				return dt.Rows.Count > 0 ? GetModel(dt.Rows[0]) : null;
			}

			public static bool Exists(System.Int32 _Id)
			{
				List<IDataParameter> paramList = new List<IDataParameter>();
				
				paramList.Add(DbAccess.CreateParameter("?Id", _Id));
				
				return Convert.ToInt32(DbAccess.ExecuteScalar(SQL_EXISTS + " AND Id=?Id", CommandType.Text, paramList.ToArray())) > 0;
			}

			
		}
		#endregion

}